/**
 * 
 * © Bahadir Zeren 2011
 * bzeren@gmail.com
 * No warranties, express or implied, are made for this program.
 * 
 */

package org.baatar.opt.genetic;

import java.util.EventListener;
import org.baatar.opt.genetic.chromosome.IChromosome;

/**
 * Listener class which is triggered when a genetic iteration is completed.
 * 
 */
public interface GeneticIterationListener<T, M> extends EventListener {

    /**
     * Metod which is called after each progress.
     * 
     * @param optimizerIndex index # of the optimizer  (important for parallel implementation)
     * @param iteration iteration number.
     * @param elapsedTime elapsed time until this iteration.
     * @param info String representation of the best individual.
     */
    public void onProgress(int optimizerIndex,
                            int iteration,
                            double elapsedTime,
                            String info);

//    /**
//     * Metod which is called after each genetic iteration.
//     * 
//     * @param optimizerIndex index # of the optimizer  (important for parallel implementation)
//     * @param iteration current iteration step.
//     * @param numOfIterationsPassedWOProgress Number of iterations passed without progress.
//     * @param maxNumOfIterations maximum number of iterations algorithm can reach.
//     */
//    public void onIterate(int optimizerIndex,
//                            int iteration,
//                            int numOfIterationsPassedWOProgress,
//                            int maxNumOfIterations);

    /**
     * Metod which is called when migration needed for parallel implementation.
     * 
     * @param optimizerIndex index # of the optimizer  (important for parallel implementation)
     * @param iteration current iteration step.
     * @param migrants array of migrants to migrate.
     */
    public void onMigrationNeeded(int optimizerIndex,
                                    int iteration,
                                    IChromosome<T, M> migrants[]);

    /**
     * Metod which is called if an exception occured.
     * 
     * @param optimizerIndex index # of the optimizer  (important for parallel implementation)
     * @param exceptionMessage message of the exception.
     */
    public void onException(int optimizerIndex,
                            String exceptionMessage);
}
